@extends('admin.common.base-master')

@section('html-head')
    <link href="{{url('css/jquery.form.css')}}" type="text/css" rel="stylesheet" />
    <script src="{{url('/js/lib/jquery.form.js')}}"></script>

    <style>
        .sx{
            padding-left: 32px;
        }
        .sx-btn{width: 64px;height: 30px;background-color: #4dbcd3;color: #fff;border: #4dbcd3;border-radius: 7%;}
        .autocomplete-button{
            display: none;
        }
        .proposal-list li{
            background-color: white !important;
        }
        li.proposal.selected{
            background-color: rgb(175, 42, 0) !important;
        }
        .select-box{
            position: relative;
            width: 30%;
            float: left;
            height: 100px;
        }
        .select-btn{
            width: 100px;height: 33px;
            background-color: #4dbcd3;
            color: #fff;
            border: #4dbcd3;
            /*border-radius: 7%;*/
            /*position: absolute;*/
            /*top: 80%;*/
            /*margin: -50px 0 0 0;*/
            /*line-height: 100px;*/
        }
    </style>
@endsection

@section('html-body')
    <!-- content start -->
    <div id="content">
        <!-- cur-position start -->
        <div id="cur-position">
            <span class="tit">活动分类列表</span>
        </div>

        <!-- 二级目录 -->
        @include('admin.common.web-info-header')

        <div class="filter-box clearfix">
            <div class="fr">
                @if($type == 'application')
                    <a class="addBtn" href="{{route('Admin.Home.applicationFieldSet')}}">新增</a>
                @else
                    <a class="addBtn" href="{{route('Admin.Home.enApplicationFieldSet')}}">新增</a>
                @endif
            </div>
        </div>

        <div class="table-box">
            <table class="table">
                <thead>
                <tr>
                    <th>Id</th>
                    <th>名称</th>
                    <th>封面图</th>
                    <th>缩略图</th>
                    <th>描述</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @if(count($applicationFieldList) > 0)
                    @foreach($applicationFieldList as $applicationField)
                        <tr id="huge_{{$applicationField->id}}">
                            <td>{{$applicationField->id}}</td>
                            <td>{{$applicationField->name}}</td>
                            <td class="account-td" style="width: 5%;">
                                <span class="photo" style="border-radius: 100%;display:initial">
                                    @if($applicationField->img_id !== 0)
                                    <a target="_blank" href="{{$applicationField->img_url}}" class="openimg" data-key="{{$applicationField->img_id}}"><img src="{{$applicationField->img_url}}" alt=""></a>
                                    @else
                                    <img src="{{url('images/noimg,gif')}}" alt="">
                                    @endif
                                </span>
                            </td>
                            <td class="account-td" style="width: 5%;">
                                <span class="photo" style="border-radius: 100%;display:initial">
                                    @if($applicationField->thumb_img_id !== 0)
                                        <a target="_blank" href="{{$applicationField->thumb_img_url}}" class="openimg" data-key="{{$applicationField->thumb_img_id}}"><img src="{{$applicationField->thumb_img_url}}" alt=""></a>
                                    @else
                                        <img src="{{url('images/noimg,gif')}}" alt="">
                                    @endif
                                </span>
                            </td>
                            <td>{{$applicationField->desc}}</td>
                            <td>
                                @if($type == 'application')
                                    <a class="color2" href="{{route("Admin.Home.applicationFieldSet")}}?id={{$applicationField->id}}">编辑</a>
                                @else
                                    <a class="color2" href="{{route("Admin.Home.enApplicationFieldSet")}}?id={{$applicationField->id}}">编辑</a>
                                @endif
                                <span>|</span>
                                <a href="javascript:void(0);" class="del" data-id="{{$applicationField->id}}" data-type="{{$type}}">删除 </a>
                            </td>
                        </tr>
                    @endforeach
                @endif
                </tbody>
            </table>
        </div>

    </div>

    <script>

        $(function () {

            $(document).on("click",".del",function() {
                var id = $(this).attr("data-id");
                var type = $(this).attr("data-type");

                noty({
                    text: '你确定要删除吗?',
                    buttons: [
                        {
                            addClass: 'btn btn-primary', text: '确定', onClick: function ($noty) {
                            $noty.close();
                            $.ajax({
                                url: '{{route('Api.Admin.sys.delApplicationField')}}',
                                type: 'post',
                                dataType: 'json',
                                data: {id: id,type:type},
                                success: function (obj) {
                                    if (obj.level == "success") {
                                        /*
                                         window.location.reload();
                                         */
                                        $("#huge_" + id).hide('slow');

                                    } else {
                                        noty({type: obj.level, text: obj.message, timeout: 600});
                                    }
                                },
                                error: function (obj) {
                                    console.log(obj);
                                }

                            });
                        }
                        },
                        {
                            addClass: 'btn btn-danger', text: '取消', onClick: function ($noty) {
                            $noty.close();
                        }
                        }
                    ]
                });
            });
        })
    </script>
@endsection